*********************************************************************
* The Young and the Hawkish:                                        *
* Generational Differences in Conflict Attitudes in Israel  		*
* by Liran Harsgor													*
*                                                                   *
* Replication code                    					            * *********************************************************************
* The analysis was performed with Stata 17. For model presentation, *
* users should install the estout package							* 
* (command line: "ssc install estout, replace").					*
*																	*
* to load the data (the "use" command), users should place the .dta	*
* file in their Stata working directory (or type the full file 		*
* paths as saved on their computer).                      			*
*********************************************************************

use "INES81-19.dta"

set scheme  s1mono  


** Survey weight
sum year
scalar N=r(N)
egen year_tag=tag(year)
count if year_tag==1
scalar Nsurveys=r(N)
scalar avgN=N/Nsurveys
by year, sort: egen Nyear=count(year)
gen weight=avgN/Nyear

** Rocodes
replace peace_chance_new = (peace_chance_new-1)/(4-1)
replace peace_chance_new = 1-peace_chance_new

gen birthyear=year-age

recode age (18/21=1) (22/30=2) (31/50=3) (51/100=4), gen(agecat)

gen cohort3=.
replace cohort3=1 if birthyear<1940
replace cohort3=2 if birthyear>=1940 & birthyear<1945
replace cohort3=3 if birthyear>=1945 & birthyear<1950
replace cohort3=4 if birthyear>=1950 & birthyear<1955
replace cohort3=5 if birthyear>=1955 & birthyear<1960
replace cohort3=6 if birthyear>=1960 & birthyear<1965
replace cohort3=7 if birthyear>=1965 & birthyear<1970
replace cohort3=8 if birthyear>=1970 & birthyear<1975
replace cohort3=9 if birthyear>=1975 & birthyear<1980
replace cohort3=10 if birthyear>=1980 & birthyear<1985
replace cohort3=11 if birthyear>=1985 & birthyear<1990
replace cohort3=12 if birthyear>=1990 & birthyear<1995
replace cohort3=13 if birthyear>=1995 & birthyear<2005

gen cohort4=.
replace cohort4=1 if birthyear<1940
replace cohort4=2 if birthyear>=1940 & birthyear<1960
replace cohort4=3 if birthyear>=1960 & birthyear<1980
replace cohort4=4 if birthyear>=1980 & birthyear<1990
replace cohort4=5 if birthyear>=1990 & birthyear<2005


* label values for cohort3
label define cohort_label 1 "Before 1940" ///
						  2 "1940-1944" ///
                          3 "1945-1949" ///
                          4 "1950-1954" ///
                          5 "1955-1959" ///
                          6 "1960-1964" ///
                          7 "1965-1969" ///
                          8 "1970-1974" ///
                          9 "1975-1979" ///
                          10 "1980-1984" ///
                          11 "1985-1989" ///
                          12 "1990-1994" ///
                          13 "1995-2001" ///
						  
* Assign the "cohort_labels" value label to the "cohort" variable
label values cohort3 cohort_label

* label values for cohort4
label define cohort4_label 1 "Before 1940" ///
						  2 "1940-1959" ///
                          3 "1960-1979" ///
                          4 "1980-1989" ///
                          5 "1990-2001" 
						  
* Assign the "cohort_labels" value label to the "cohort" variable
label values cohort4 cohort4_label


** label values for age categories
label define agecat_label 1 "18-21" ///
						  2 "22-30" ///
                          3 "31-50" ///
                          4 "51 and above"
						  
* Assign the "cohort_labels" value label to the "cohort" variable
label values agecat agecat_label

egen ctag3=tag(year cohort3)
egen ctag4=tag(year cohort4)



** FIGURE 1

bysort year cohort3: egen freqcy3=count(pal_state)
bysort year cohort3: egen meanpal3=mean(pal_state)

local election_years "1981 1984 1988 1992 1996 1999 2003 2006 2009 2013 2015 2019"
twoway (line meanpal3 year if cohort3==1 & ctag3==1 & freqcy3>30, lcolor(gs10) lpattern(shortdash_dot_dot) lwidth(medthin) legend(label(1 "before 1940"))) ///
       (line meanpal3 year if cohort3==2 & ctag3==1 & freqcy3>30, lcolor(gs10) lpattern(dash) lwidth(medthin) legend(label(2 "1940-1944"))) ///
       (line meanpal3 year if cohort3==3 & ctag3==1 & freqcy3>30, lcolor(black) lpattern(dot) lwidth(medthin) legend(label(3 "1945-1949"))) ///
       (line meanpal3 year if cohort3==4 & ctag3==1 & freqcy3>30, lcolor(gs10) lpattern(dash_dot) lwidth(thin) legend(label(4 "1950-1954"))) ///
       (line meanpal3 year if cohort3==5 & ctag3==1 & freqcy3>30, lcolor(gs9) lpattern(longdash) lwidth(thin) legend(label(5 "1955-1959"))) ///
       (line meanpal3 year if cohort3==6 & ctag3==1 & freqcy3>30, lcolor(gs9) lpattern(shortdash) lwidth(medthin) legend(label(6 "1960-1964"))) ///
       (line meanpal3 year if cohort3==7 & ctag3==1 & freqcy3>30, lcolor(gs9) lpattern(shortdash_dot) lwidth(thin) legend(label(7 "1965-1969"))) ///
       (line meanpal3 year if cohort3==8 & ctag3==1 & freqcy3>30, lcolor(gs12) lpattern(solid) lwidth(thin) legend(label(8 "1970-1974"))) ///
	   (line meanpal3 year if cohort3==9 & ctag3==1 & freqcy3>30, lcolor(gs4) lpattern(shortdash) legend(label(9 "1975-1979"))) ///
	    (line meanpal3 year if cohort3==10 & ctag3==1 & freqcy3>30, lcolor(gs4) lpattern(solid) legend(label(10 "1980-1984"))) ///
		(line meanpal3 year if cohort3==11 & ctag3==1 & freqcy3>30, lcolor(gs3) lpattern(dash_dot) legend(label(11 "1985-1989"))) ///
		(line meanpal3 year if cohort3==12 & ctag3==1 & freqcy3>30, lcolor(gs2) lpattern(shortdash_dot_dot) legend(label(12 "1990-1994"))) ///
		(line meanpal3 year if cohort3==13 & ctag3==1 & freqcy3>30, lcolor(gs1) lpattern(dash) legend(label(13 "1995-2005"))), ///
	   xlabel(`election_years', labsize(vsmall) angle(45)) ///
       ytitle("Level of support for a Palestinian state", size(small)) ///
	   xtitle("Election year", size(small)) ///
       legend(order(1 2 3 4 5 6 7 8 9 10 11 12 13) size(vsmall) cols(4) ///
	   title("Birth years", size(small) position(11))) ylabel(0(0.1)0.7)

	   

** Regressions

*** TABLE B1
 
eststo clear
eststo:  reg pal_state ib3.agecat i.year [w=weight] 
	estimates store model1
eststo:  reg pal_state ib3.agecat i.cohort3 i.year [w=weight]
	estimates store model2
eststo: reg pal_state ib3.agecat i.cohort3 ethnic relig_obs income education i.year [w=weight]
	estimates store model3

esttab model1 model2 model3 using TableB1.rtf,  ///
	b(3) se(3) r2 ///
	drop(*year) ///
	star(* 0.05 ** 0.01 *** 0.001) ///
	nogaps compress 

*** TABLE B2
 
eststo clear
eststo:  reg RL_self ib3.agecat i.year [w=weight] 
	estimates store model1
eststo:  reg RL_self ib3.agecat i.cohort3 i.year [w=weight]
	estimates store model2
eststo: reg RL_self ib3.agecat i.cohort3 ethnic relig_obs income education i.year [w=weight]
	estimates store model3

esttab model1 model2 model3 using TableB2.rtf,  ///
	b(3) se(3) r2 ///
	drop(*year) ///
	star(* 0.05 ** 0.01 *** 0.001) ///
	nogaps compress 
	
*** TABLE B3

eststo clear
eststo:  reg pal_state ib3.agecat i.cohort3 i.year [iw=weight] if relig_obs<=0.6
	estimates store model1
eststo:  reg pal_state ib3.agecat i.cohort3 i.year [iw=weight] if relig_obs>0.6
	estimates store model2
	
esttab model1 model2  using TableB3.rtf,  ///
	b(3) se(3) r2 ///
	drop(*year) ///
	star(* 0.05 ** 0.01 *** 0.001) ///
	nogaps compress 


*** TABLE B4

eststo clear
eststo:  reg pal_state ib3.agecat i.cohort3 ethnic relig_obs income education i.year if year>2005 & peace_chance_new!=.  [w=weight] 
	estimates store model1
eststo:  reg pal_state peace_chance_new ib3.agecat i.cohort3 ethnic relig_obs income education i.year if year>2005 [w=weight]
	estimates store model2

esttab model1 model2  using TableB4.rtf,  ///
	b(3) se(3) r2 ///
	star(* 0.05 ** 0.01 *** 0.001) ///
	nogaps compress 


*** FIGURE 2

reg pal_state ib3.agecat i.cohort3 ethnic relig_obs income education i.year [w=weight]
margins cohort3
marginsplot, xlabel(, labsize(vsmall) angle(45)) ///
xtitle("Birth-years") ///
ytitle("Predicted support for a Palestinian state") ylabel(0(0.2)0.8) ///
title("A. Support for a Palestinian state")

graph save "pal_cohort", replace

reg RL_self ib3.agecat i.cohort3 ethnic relig_obs income education i.year [w=weight]
margins cohort3
marginsplot, xlabel(, labsize(vsmall) angle(45)) ///
xtitle("Birth-years") ///
ytitle("Predicted self left-right position") ylabel(2(1)5) ///
title("B. Left-Right position")

graph save "RL_cohort", replace

graph combine "pal_cohort" "RL_cohort", xsize(12) ysize(7)



*** FIGURE 3
 
reg pal_state ib3.agecat i.cohort3 ethnic relig_obs income education i.year [w=weight]
margins agecat
marginsplot, xlabel(, labsize(small) angle(45)) ///
xtitle("Age") ///
ytitle("Predicted support for a Palestinian state") ylabel(0.2(0.1)0.5) ///
title("")


*** FIGURE 4

reg pal_state ib3.agecat i.cohort3 i.year [w=weight] if relig_obs<=0.6
margins cohort3
marginsplot, xlabel(, labsize(vsmall) angle(45)) ///
xtitle("Birth-years") ///
ytitle("") ///
title("Low religious obsrvance")  ylabel(0(0.1)0.7)
graph save "secular", replace

reg pal_state ib3.agecat i.cohort3 i.year [w=weight] if relig_obs>0.6
margins cohort3
marginsplot, xlabel(, labsize(vsmall) angle(45)) ///
xtitle("Birth-years") ///
ytitle("Predicted support for a Palestinian state") ///
title("High religious observance")  ylabel(0(0.1)0.7)
graph save "relig", replace

graph combine  "relig" "secular", xsize(12) ysize(7)



** FIGURE 5

bysort year cohort4: egen freqcy6=count(peace_chance_new)
bysort year cohort4: egen meanpeace=mean(peace_chance_new)

local election_years "2006 2009 2013 2015 2019"
twoway (line meanpeace year if cohort4==1 & ctag4==1 & freqcy6>30, lcolor(black) lpattern(shortdash_dot_dot) lwidth(thin) legend(label(1 "Before 1940"))) ///
       (line meanpeace year if cohort4==2 & ctag4==1 & freqcy6>30, lcolor(gs5) lpattern(dash) lwidth(thin) legend(label(2 "1940-1959"))) ///
       (line meanpeace year if cohort4==3 & ctag4==1 & freqcy6>30, lcolor(black) lpattern(solid) lwidth(medthin) legend(label(3 "1960-1979"))) ///
       (line meanpeace year if cohort4==4 & ctag4==1 & freqcy6>30, lcolor(gs1) lpattern(dash_dot) lwidth(thin) legend(label(4 "1980-1989"))) ///
       (line meanpeace year if cohort4==5 & ctag4==1 & freqcy6>30, lcolor(black) lpattern(longdash) lwidth(thin) legend(label(5 "1990-2001"))), ///
	   xlabel(`election_years', labsize(small) angle(45)) ///
       ytitle("Level of hope", size(medium)) ///
	   xtitle("Survey year", size(small)) ///
       legend(order(1 2 3 4 5) size(small) cols(3) ///
	   title("Birth years", size(small) position(11))) ylabel(0(0.1)0.7)
	   
	   



